package blocos;

import blocos.DiferentsBlocks;

public class BlockBit extends Block{
	String value;
	
	public BlockBit(String v){
		if(v.compareToIgnoreCase("0")==0){
			value=String.valueOf(0);
		}
		else if(v.compareToIgnoreCase("1")==0){
			value=String.valueOf(1);
		}
		else{
			value="?";
		}
		
	}
	
	void attachRight (Block a ) throws DiferentsBlocks 
	{
		if ((a instanceof blocos.BlockLogic )||(a instanceof blocos.BlockWire))
		{
			
			super.attachRight(a);
		}
		else
		{
		    throw new DiferentsBlocks();
		}
	}
	
	void attachLeft (Block a ) throws DiferentsBlocks 
	{

		if ((a instanceof blocos.BlockLogic )||(a instanceof blocos.BlockWire))
		{
			super.attachLeft(a);
		
		}
		else
		{
		    throw new DiferentsBlocks();
		}

	}

	void attachTop (Block a ) throws DiferentsBlocks 
	{
		
		if ((a instanceof blocos.BlockLogic )||(a instanceof blocos.BlockWire))
		{
			
			super.attachTop(a);
			
		}
		else
		{
		    throw new DiferentsBlocks();
		}
	}
	
	void attachBottom (Block a ) throws DiferentsBlocks 
	{

		if ((a instanceof blocos.BlockLogic )||(a instanceof blocos.BlockWire))
		{
			super.attachBottom(a);
			
		}
		else
		{
		    throw new DiferentsBlocks();
		}
	}

	
	
	//persistencia
	
	public String[] save() {
		String [] a  = new String[1];
		a[0]=this.value;
		return a ;
	}

}
